package com.ruoyi.buss.khjl.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.PreAuthorize;
import com.ruoyi.buss.khjl.domain.DataUserKhjljf;
import com.ruoyi.buss.khjl.service.IDataUserKhjljfService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 客户经理积分Controller
 * 
 * @author sxy
 * @date 2021-07-16
 */
@RestController
@RequestMapping("/khjljf")
public class DataUserKhjljfController extends BaseController
{
    @Autowired
    private IDataUserKhjljfService dataUserKhjljfService;

    /**
     * 查询客户经理积分列表
     */
    @PreAuthorize(hasPermi = "buss:khjljf:list")
    @GetMapping("/list")
    public TableDataInfo list(DataUserKhjljf dataUserKhjljf)
    {
        startPage();
        List<DataUserKhjljf> list = dataUserKhjljfService.selectDataUserKhjljfList(dataUserKhjljf);
        return getDataTable(list);
    }

    /**
     * 导出客户经理积分列表
     */
    @PreAuthorize(hasPermi = "buss:khjljf:export")
    @Log(title = "客户经理积分", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DataUserKhjljf dataUserKhjljf) throws IOException
    {
        List<DataUserKhjljf> list = dataUserKhjljfService.selectDataUserKhjljfList(dataUserKhjljf);
        ExcelUtil<DataUserKhjljf> util = new ExcelUtil<DataUserKhjljf>(DataUserKhjljf.class);
        util.exportExcel(response, list, "客户经理积分数据");
    }

    /**
     * 获取客户经理积分详细信息
     */
    @PreAuthorize(hasPermi = "buss:khjljf:query")
    @GetMapping(value = "/{tjrq}")
    public AjaxResult getInfo(@PathVariable("tjrq") String tjrq)
    {
        return AjaxResult.success(dataUserKhjljfService.selectDataUserKhjljfById(tjrq));
    }

    /**
     * 新增客户经理积分
     */
    @PreAuthorize(hasPermi = "buss:khjljf:add")
    @Log(title = "客户经理积分", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DataUserKhjljf dataUserKhjljf)
    {
        return toAjax(dataUserKhjljfService.insertDataUserKhjljf(dataUserKhjljf));
    }

    /**
     * 修改客户经理积分
     */
    @PreAuthorize(hasPermi = "buss:khjljf:edit")
    @Log(title = "客户经理积分", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DataUserKhjljf dataUserKhjljf)
    {
        return toAjax(dataUserKhjljfService.updateDataUserKhjljf(dataUserKhjljf));
    }

    /**
     * 删除客户经理积分
     */
    @PreAuthorize(hasPermi = "buss:khjljf:remove")
    @Log(title = "客户经理积分", businessType = BusinessType.DELETE)
	@DeleteMapping("/{tjrqs}")
    public AjaxResult remove(@PathVariable String[] tjrqs)
    {
        return toAjax(dataUserKhjljfService.deleteDataUserKhjljfByIds(tjrqs));
    }
}
